/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lifecraft;

import java.util.Random;

interface Block {
    int Update();
    void Draw(int x, int y);
    SurfC GetID();
    int GetType();
    int Set(int What, int HowMany);
    int GetIndex();
    void setIndex(int index);
}

class Solid implements Block {
    public int x;
    public int y;
    public float txth;
    public float txtw;
    public SurfC ID;
    Surface surface;
    public int Index;
    public int GetType(){
        return 1;
    }
    public int GetIndex(){
       return Index;
    }
    public void setIndex(int index){
       Index=index;
    }
    public int Update(){
        return 0;
    }
    public void Draw(int x, int y){
         surface.useLight(this.x*32+x, this.y*32+y, 32, 32, txtw, txth, 1);
    }
    public Solid( int X, int Y,SurfC ID){
        Random rand = new Random();
        txth=rand.nextInt(4);
        txth/=4;
        txtw=rand.nextInt(4);
        txtw/=4;
        
        x=X;
        y=Y;
        Index=x*27+y;
        this.ID=ID;   
        
        
        surface=SurfaceBase.get().getFromID(ID);
    }
    public int Set(int What, int HowMany){
        
        return 0;
    }
    public SurfC GetID(){
        return ID;
    }
}

class Liquid implements Block {
    public int x;
    public int y;
    public SurfC ID;
    Surface surface;
    public int FillLevel;
    public int Index;
    public int GetType(){
        return 2;
    }
    public int GetIndex(){
       return Index;
    }
    public void setIndex(int index){
       Index=index;
    }
    public int Update() {
        return 1;
    }
    public void Draw(int x, int y) {
        surface.useLight(this.x*32+x, this.y*32+y, 32, FillLevel,0,0, 1);
    }
    public Liquid(int X, int Y, SurfC ID, int Fill){
        x=X;
        y=Y;
        this.ID=ID;     
        surface=SurfaceBase.get().getFromID(ID);
        Index=x*27+y;
        FillLevel=Fill;
        
    }
    public int Set(int What, int HowMany) {
        if(What==-1)
            FillLevel--;
        if(What==1)
            FillLevel++;
        return FillLevel;
    }
    public SurfC GetID()
    {
        return ID;
    }
}


class Air implements Block {
    public int x;
    public int y;
    public SurfC ID;
    public int Index;
    public float txtw;
    public float txth;
    Surface surface;
    public int GetType(){
        return 0;
    }
    
    public int GetIndex(){
       return Index;
    }
    public void setIndex(int index){
       Index=index;
    }
   
    public int Update(){
        return 0;
    }
    public void Draw(int x, int y){
        if(ID!=SurfC.AIR)
            surface.useLight(this.x*32+x, this.y*32+y, 32, 32, txtw, txth, 1);
    }
    public Air( int X, int Y,SurfC ID){
        x=X;
        y=Y;
        Index=x*27+y;
        this.ID=ID;    
        if(ID!=SurfC.AIR){
            Random rand = new Random();
            txth=rand.nextInt(4);
            txth/=4;
            txtw=rand.nextInt(4);
            txtw/=4;
        
            surface=SurfaceBase.get().getFromID(ID);
        }
    }
    public int Set(int What, int HowMany){
        
        return 0;
    }
    public SurfC GetID(){
        return ID;
    }
}
